package com.itheima.springbootmybatis.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.springbootmybatis.domain.Student;
import com.itheima.springbootmybatis.domain.TargetLinkConf;
import com.itheima.springbootmybatis.mapper.TargetLinkConfMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

@Service
public class TargetLinkConfServiceImpl extends ServiceImpl<TargetLinkConfMapper, TargetLinkConf> implements TargetLinkConfService {

    @Autowired
    private TargetLinkConfMapper targetLinkConfMapper ;


    /**
     * 根据主编码查询出关联配置表
     * @param masterTargetCode
     * @return
     */
    @Override
    public TargetLinkConf chaxun(String masterTargetCode) {
        if(masterTargetCode != null){
            TargetLinkConf targetLinkConf = targetLinkConfMapper.chaxun(masterTargetCode);
            return targetLinkConf ;
        }
        return null;
    }

    /**
     * 根据主编码查询子编码
     * @param masterTargetCode
     * @return
     */
    @Override
    public List<String> queryZBIdByz(String masterTargetCode) {
        List<String> list = targetLinkConfMapper.queryZBIdByz(masterTargetCode);
        if (list != null || list.size() != 0){
            return list ;
        }
        return null ;
    }

    /**
     * 根据从指标查询配置表
     * @param
     * @param dmtype
     * @return
     */

    @Override
    public List<Map<String, Object>> queryAllZB(String dmtype,String masterTargetCode) {

        Map<String,Object> map = new HashMap<>() ;

        List<String> list = targetLinkConfMapper.queryZBIdByz(masterTargetCode);

        for (String items : list) {

        }

        return null ;

    }

   /* public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        Student student1 = new Student(6,"张三",24,6) ;
        Student student2 = new Student(3,"李四",25,1) ;
        Student student3 = new Student(2,"张三三",26,3) ;
        Student student4 = new Student(4,"王五",27,4) ;

        list.add(student1);
        list.add(student2);
        list.add(student3);
        list.add(student4);

        list.stream().sorted(Comparator.comparing(Student::getId)).collect(Collectors.toList());

        list.forEach(student -> {
            System.out.println(student);
        });*/

   // }
}
